package com.maple.callback.event.boot.service;

import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import com.maple.callback.event.boot.User;
import com.maple.callback.event.boot.UserRegisterEvent;

@Service
public class UserService {
	
	@Autowired
	private ApplicationContext applicationContext;
	
	/**
     * 用户注册方法
     * @param user
     */
    public void register(User user){
    	
    	try {
			TimeUnit.SECONDS.sleep(2);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
        
    	//发布UserRegisterEvent事件
        applicationContext.publishEvent(new UserRegisterEvent(this,user));
    }
    
    
}
